﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

/// <summary>
/// Summary description for Products
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Products : System.Web.Services.WebService {

    public Products () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string [] GetPRDList(string prefixText)
    {
        string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

        string selectString = "SELECT product from products WHERE product LIKE '" + prefixText + "%'";
        string [] ds =new string[20];
         (DB.getdata(selectString)).Tables[0].Rows.CopyTo(ds,0);
        return ds;
        
       
        //List<String> ACTList = new List<string>(10);
        //using (SqlConnection sqlConn = new SqlConnection(connString))
        //{
        //    sqlConn.Open();

        //    using (SqlCommand sqlCmd = new SqlCommand(selectString, sqlConn))
        //    {
        //        SqlDataReader reader = sqlCmd.ExecuteReader();
        //        while (reader.Read())
        //            ACTList.Add(reader[0].ToString());
        //    }
        //    sqlConn.Close();
        //}

        //return (ACTList.ToArray());
    }   
    
}

